class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2024-08-05",
      revision: "507bd26e3e79561b1219d0d77d6388463a8060ce"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sonoma:   "34298a773f1706cc7562dcb28717faec0da3e9ee6010e4d7d0a89f045445cff4"
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "04c5190cbbb7785020fe0eb6a792160b4e3a652915b9a7f46d701c0ffab01fd4"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "acec3fe71eb26608faff09ec49bf799f02fb319aebaf3571067999e0c783e949"
    sha256 cellar: :any_skip_relocation, sonoma:         "93abcf3f4694c172efb958fab3c7028a4c085f4bfe540d60d0aa414c06c56900"
    sha256 cellar: :any_skip_relocation, ventura:        "4433aa94236ab06f03542e65b4d86c2401d4a531a5579968d11f0be5d9669cb7"
    sha256 cellar: :any_skip_relocation, monterey:       "ac391e2b6455b72fe534e4a1ca3e0d6d62429ebcf2501e32241b1d9537d3fbad"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "023baf3c3a63010261910e24f5b90bb51f2fb80ee3d2d9bf675f0fb0b390f4d0"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system bin/"searchsploit", "sendpage"
  end
end
